<template >
  <div class="wrap-table fllow-manage">
    <el-form ref="form" :model="searchData" label-width="100px" class="clearfix flex-div">
      <el-form-item label="预约日期" class label-width="70px" style="width:340px">
        <div class="block">
          <el-date-picker
            v-model="timeDate"
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            value-format="yyyy-MM-dd"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
          ></el-date-picker>
        </div>
      </el-form-item>
      <el-form-item label="预约状态" class style="width: 200px">
        <el-select v-model="searchData.appointState" clearable placeholder="请选择">
          <el-option
            v-for="item in options2"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="事项状态" class style="width: 200px">
        <el-select v-model="searchData.itemState" clearable placeholder="请选择">
          <el-option
            v-for="item in options3"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所在地区" class="item-right" style="width:200px">
        <el-select
          v-model="searchData.districtNo"
          placeholder="请选择"
          @change="changeDis"
          clearable
          :disabled="JSON.parse(UserDic).IsCommunityOnly=='1'"
        >
          <el-option
            v-for="item in optionDiq"
            :key="item.DistrictName"
            :label="item.DistrictName"
            :value="item.DistrictNo"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所在社区" class="item-right" style="width:170px">
        <el-select
          v-model="CtyIds"
          placeholder="请选择"
          @change="Commutysp"
          clearable
          :disabled="JSON.parse(UserDic).IsCommunityOnly=='1'"
        >
          <el-option
            v-for="item in optionsData"
            :key="item.SYS_ID"
            :label="item.CName"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="采集时研究阶段" label-width="120px" class style="width:220px">
        <el-select v-model="searchData.period" clearable placeholder="请选择">
          <el-option
            v-for="item in options2sp"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="数据采集时段" label-width="120px" class style="width:220px">
        <el-select v-model="searchData.collectPeriod" clearable placeholder="请选择">
          <el-option
            v-for="item in collectTion"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="试验类型" class="item-right" style="width:260px">
        <el-select v-model="searchData.testType" clearable placeholder="请选择">
          <el-option
            v-for="item in options6"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item class label>
        <el-input
          v-model="searchData.keyWord"
          style="width: 210px;margin-left: -60px;"
          placeholder="研究对象手机号、研究编号"
        ></el-input>
      </el-form-item>
      <div class="flex-r-but">
        <el-button type="success" @click="outPut" class="mg-lr-20 pd-bt">导出</el-button>
        <el-button type="primary" @click="checkList" class="mg-lr-20 pd-bt">查询</el-button>
      </div>
    </el-form>
    <!---->
    <template>
      <el-table
        :data="tableData"
        border
        id="outtableFirst"
        v-loading="loading"
        element-loading-text="加载中"
        style="width: 100%"
      >
        <el-table-column prop="AppointDate" align="center" label="预约日期" min-width="160">
          <template slot-scope="scope">
            <span class="excelHidden">({{scope.row.AppointDate}})</span>
            <el-date-picker
              v-model="scope.row.AppointDate"
              :clearable="false"
              :disabled="true"
              @change="changeFollowUpDate(scope.row,scope.row.AppointDate)"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
            ></el-date-picker>
          </template>
        </el-table-column>
        <el-table-column prop="AppointTime" label="预约时间" align="center" min-width="120">
          <template slot-scope="scope">
            <span class="excelHidden">({{scope.row.AppointTime}})</span>
            <el-time-select
              v-model="scope.row.AppointTime"
              :clearable="false"
              @change="changeFollowUpDateOne(scope.row,scope.row.AppointTime)"
              :picker-options="{start: '08:00', step: '00:15',end: '21:30'}"
              placeholder
            ></el-time-select>
          </template>
        </el-table-column>
        <el-table-column
          prop="ScheduleName"
          label="事项标题"
          align="center"
          :show-overflow-tooltip="true"
          min-width="120"
        ></el-table-column>
        <el-table-column
          prop="AppointState"
          label="预约状态"
          align="center"
          :formatter="AppointFilter"
          min-width="120"
        >
          <template slot-scope="scope">
            <span class="excelHidden">{{scope.row.AppointFilter}}</span>
            <span class="excelHidden">({{scope.row.AppointState |AppointState}})</span>
            <el-select
              v-model="scope.row.AppointState"
              placeholder="请选择"
              @change="changeFollowUpDate(scope.row,scope.row.AppointState)"
            >
              <el-option
                v-for="item in options2s"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column
          prop="ItemState"
          label="事项状态"
          :formatter="FollowUpFilter"
          align="center"
          min-width="120"
        >
          <template slot-scope="scope">
            <span class="excelHidden">({{scope.row.ItemState |FollowUpState}})</span>
            <el-select
              v-model="scope.row.ItemState"
              placeholder="请选择"
              @change="changeFollowUpDate(scope.row,scope.row.ItemState)"
            >
              <el-option
                v-for="item in options3s"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="Nurse" label="数据采集员" align="center" min-width="120">
          <template slot-scope="scope">
            <span class="excelHidden">({{scope.row.Nurse || '-'}})</span>
            <el-select
              v-model="scope.row.Nurse"
              placeholder="请选择"
              @change="changeNurse(scope.row,scope.row.Nurse)"
            >
              <el-option
                v-for="item in optionsNurse"
                :key="item.SYS_ID"
                :label="item.icons"
                :value="item.icons"
              ></el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column prop="Surname" label="姓名首字母" align="center" min-width="100"></el-table-column>
        <el-table-column label="手机号" align="center" min-width="100">
          <template slot-scope="scope">
            <el-tooltip :content="scope.row.Mobile" placement="top">
              <span
                class="click_line"
                @click="JumpUserinfo(scope.row)"
              >{{scope.row.Mobile |mobileFilter}}</span>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column
          prop="Period"
          label="采集时研究阶段"
          :formatter="PeriodFilter"
          align="center"
          min-width="150"
        ></el-table-column>
         <el-table-column
          prop="CollectPeriod"
          label="数据采集时段"
          align="center"
          min-width="220"
        >
          <template slot-scope="scope">
            <!-- <span class="excelHidden">({{scope.row.CollectPeriod |CollectPeriod}})</span> -->
            <el-select
              v-model="scope.row.CollectPeriod"
              placeholder="请选择"
              @change="changeFollowUpDate(scope.row,scope.row.CollectPeriod)"
            >
              <el-option
                v-for="item in collectTion"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </template>
        </el-table-column>
        <el-table-column
          prop="DistrictName"
          :formatter="DistrictNameFilter"
          label="所在地区"
          align="center"
          min-width="100"
        ></el-table-column>
        <el-table-column prop="CName" label="所在社区" align="center" min-width="100"></el-table-column>
        <el-table-column
          prop="IntensityOfIntervention"
          label="采集时干预强度"
          :formatter="IntensityFilter"
          align="center"
          min-width="150"
        ></el-table-column>
        <el-table-column
          prop="UserState"
          label="对象状态"
          :formatter="UserStateFilter"
          align="center"
          min-width="100"
        ></el-table-column>
        <el-table-column prop="Remark" label="事项备注" align="center" min-width="120">
          <template slot-scope="scope">
            <span class="excelHidden">{{scope.row.Remark ||'-'}}</span>
            <el-input
              @blur="changeFollowUpDate(scope.row,scope.row.Remark)"
              v-model="scope.row.Remark"
              placeholder="事项备注"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="CancleReason" label="事项取消原因" align="center" min-width="160">
          <template slot-scope="scope">
            <span class="excelHidden">{{scope.row.CancleReason ||'-'}}</span>
            <el-input
              @blur="changeFollowUpDate(scope.row,scope.row.CancleReason)"
              v-model="scope.row.CancleReason"
              placeholder="事项取消原因"
            ></el-input>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <!--分页-->
    <div class="block mg-20-auto pagination-fixed">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pageId"
        :page-sizes="[10, 20, 30, 40,80,100,200,500]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import {DIC_PERIODA,filterPeriod} from '@/utils/localDic'
import FileSaver from "file-saver"; //导出
import XLSX from "xlsx";
export default {
  data() {
    return {
      searchData: {
        sysId: "",
        followUpType: "",
        appointState: "",
        itemState: "",
        collectPeriod: "",
        userState: "",
        groupType: "",
        keyWord: "",
        period: "",
        districtNo: "",
        intensityOfIntervention: "",
        NurseId: "",
        communityId: "", // 社区id
        testType: "2", // 试验类型
        NurseId: "",
      },
      // districtNo:'310105',
      CtyIds: "",
      timeDate: [],
      optionDiq: [],
      optionsData: [], //社区数据
      Companions: [],
      subDisabled: false,
      dialogForm1: false,
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      pageId: 1,
      total: null,
      loading: true,
      pageSize: 10,
      collectTion: [
        { value: "", label: "全部" },
        { value: "1", label: "孕前基线问卷PCV1" },
        { value: "2", label: "孕前3个月问卷PCV2" },
        { value: "3", label: "孕前6个月问卷PCV3" },
        { value: "4", label: "孕前9个月问卷PCV4" },
        { value: "5", label: "孕前转早孕PGV1-PC" },
        { value: "6", label: "早孕基线问卷PGV1-PG" },
        { value: "7", label: "孕6个月问卷PGV2" },
        { value: "8", label: "孕9个月问卷PGV3" },
        { value: "9", label: "分娩问卷DV4" },
        { value: "10", label: "产后42天问卷PN6w" },
        { value: "11", label: "产后3个月问卷PN3m" },
        { value: "12", label: "产后6个月问卷PN6m" },
        { value: "13", label: "产后12个月问卷PN12m" },
        { value: "14", label: "产后24个月问卷PN24m" },
        { value: "15", label: "产后36个月问卷PN36m" },
        { value: "16", label: "产后60个月问卷PN60m" },
      ],
      tableData: [],
      optionPC: [
        { value: "母乳喂养", label: "母乳喂养" },
        { value: "环境", label: "环境" },
        { value: "身体活动", label: "身体活动" },
        { value: "睡眠", label: "睡眠" },
        { value: "营养", label: "营养" },
        { value: "健康状态", label: "健康状态" },
        { value: "吸烟", label: "吸烟" },
        { value: "支持网络", label: "支持网络" },
        { value: "榜样", label: "榜样" },
      ],
      optionP: [
        { value: "母乳喂养", label: "母乳喂养" },
        { value: "环境", label: "环境" },
        { value: "营养", label: "营养" },
        { value: "身体活动", label: "身体活动" },
        { value: "心理健康", label: "心理健康" },
        { value: "睡眠", label: "睡眠" },
        { value: "吸烟", label: "吸烟" },
      ],
      options1: [
        { value: "", label: "全部" },
        { value: "1", label: "面对面" },
        { value: "2", label: "电话" },
      ],
      options5: [
        { value: "1", label: "面对面" },
        { value: "2", label: "电话" },
      ],
      options2: [
        { value: "", label: "全部" },
        { value: "0", label: "待确认" },
        { value: "1", label: "已确认" },
        { value: "2", label: "已取消" },
      ],
      options2s: [
        { value: "0", label: "待确认" },
        { value: "1", label: "已确认" },
        { value: "2", label: "已取消" },
      ],
      options3: [
        { value: "", label: "全部" },
        { value: "1", label: "已完成" },
        { value: "0", label: "待完成" },
        { value: "2", label: "已取消" },
        { value: "3", label: "爽约" },
      ],
      options3s: [
        { value: "1", label: "已完成" },
        { value: "0", label: "待完成" },
        { value: "2", label: "已取消" },
        { value: "3", label: "爽约" },
      ],
      options4: [
        { value: "", label: "全部" },
        { value: "1", label: "活跃" },
        { value: "2", label: "不活跃" },
      ],
      optionss6: [
        { value: "", label: "全部" },
        { value: "1", label: "A" },
        { value: "2", label: "B" },
      ],
      options6: [
        { value: "", label: "全部" },
        { value: "0", label: "预试验" },
        { value: "1", label: "正式试验" },
        { value: "2", label: "预试验+正式试验" },
      ],
      options2sp: DIC_PERIODA,
      options9: [
        { value: "", label: "全部" },
        { value: "1", label: "AA" },
        { value: "2", label: "A" },
      ],
      FollowUpTypeFilter(row, column, cellValue, index) {
        return cellValue == 1 ? "面对面" : "电话";
      },
      UserStateFilter_move(row, column, cellValue, index) {
        return cellValue == 1 ? "已发送" : "草稿";
      },
      PeriodFilter(row, column, cellValue, index) {
        return filterPeriod(cellValue)
      },
      ResultFilter(row, column, cellValue, index) {
        switch (cellValue) {
          case "1":
            return "目标达成";
            break;
          case "2":
            return "目标部分达成";
            break;
          case "3":
            return "没有改变";
            break;
          case "4":
            return "情况更糟";
        }
      },
      DistrictNameFilter(row, column, cellValue, index) {
        return cellValue || "-";
      },
      IntensityFilter(row, column, cellValue, index) {
        return cellValue == 1 ? "AA" : "A";
      },
      AppointFilter(row, column, cellValue, index) {
        return cellValue == 1 ? "已预约" : cellValue == 0 ? "待确认" : "已取消";
      },
      FollowUpFilter(row, column, cellValue, index) {
        return cellValue == 1 ? "已完成" : "待完成";
      },
      maxHeight: "",
      showtexts: ["一点也没有", "", "有一点", "", "完全有信心"],
      showtexts2: ["不重要", "", "一般", "", "非常重要"],
      sysId: "",
      ResearchObjectId: "",
      ScheduleId: "",
      showActive: false,
      dialogForm2: false,
      tableDataQ: [],
      pageIdQ: 1,
      totalQ: null,
      loadingQ: true,
      SYS_IDs: "",
      pageSizeQ: 5,
      tablerow: null,
      optionsNurse: [],
      copyObject: null,
      onOFFsub: false,
      GroupTypeFilter(row, column, cellValue, index) {
        return cellValue == "1" ? "A" : "B";
      },
      dialogFormAnli: false,
      loadingRedcore: true,
      formPoint: {},
      dataRow: {},
      rowOff: false,
      diaLoading: true,
      hasCount: false,
    };
  },
  filters: {
    IsFillInQuestionFilter(cellValue) {
      if (cellValue == 1) {
        return "已完成";
      } else if (cellValue == 0) {
        return "未完成";
      } else {
        return "-";
      }
    },
    FollowUpType(cellValue) {
      if (cellValue == 1) {
        return "面对面";
      } else if (cellValue == 2) {
        return "电话";
      } else {
        return "-";
      }
    },
    mobileFilter(cellValue) {
      if (cellValue) {
        return cellValue.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
      }
    },
    AppointState(cellValue) {
      if (cellValue == "0") {
        return "待确认";
      } else if (cellValue == "1") {
        return "已确认";
      } else if (cellValue == "2") {
        return "已取消";
      } else {
        return "-";
      }
    },
    FollowUpState(cellValue) {
      if (cellValue == "0") {
        return "待完成";
      } else if (cellValue == "1") {
        return "已完成";
      } else if (cellValue == "2") {
        return "已取消";
      } else if (cellValue == "3") {
        return "爽约";
      } else {
        return "-";
      }
    },
    FollowUpTypeFilter(cellValue) {
      return cellValue == 1 ? "面对面" : "电话";
    },
    PeriodFilters(cellValue) {
      return filterPeriod(cellValue)
    },
  },
  created() {},
  computed: {
    ...mapGetters(["userIcon", "userId", "token", "RoleGroup", "UserDic"]),
  },
  async mounted() {
    let that = this;
    let now = new Date();
    let nowTime = now.getTime();
    let day = now.getDay();
    if (day == 0) {
      //西方从周日算为第一天    2018/10/28
      day = 7;
    }
    let oneDayLong = 24 * 60 * 60 * 1000;
    let MondayTime = nowTime - (day - 1) * oneDayLong;
    let SundayTime = nowTime + (7 - day) * oneDayLong;
    let monday = dateForm(new Date(MondayTime));
    let sunday = dateForm(new Date(SundayTime));
    that.timeDate = [monday, sunday]; //初始化时间范围
    JSON.parse(localStorage.getItem("dataColleManage"))
      ? (that.searchData = JSON.parse(localStorage.getItem("dataColleManage")))
      : "";
    await that.GetCommunityDistrict();
    that.searchData.districtNo =
      JSON.parse(that.UserDic).DistrictNo || that.searchData.districtNo || "";
    if (JSON.parse(that.UserDic).IsCommunityOnly == "1") {
      await that.getComselectList();
      that.searchData.communityId = JSON.parse(that.UserDic).CommunityId || "";
      if (that.searchData.communityId) {
        that.CtyIds =
          that.optionsData.find((val) => {
            return val.SYS_ID == JSON.parse(that.UserDic).CommunityId;
          }).CName || "";
      }
    } else {
      await that.getComselectList();
      that.searchData.communityId =
        (JSON.parse(localStorage.getItem("dataColleManage")) || {})
          .communityId || "";
      that.CtyIds =
        (
          that.optionsData.find((val) => {
            return val.SYS_ID == that.searchData.communityId;
          }) || {}
        ).CName || "";
    }
    that.getList();
    that.GetNurse(); // 获取干预护士
  },
  beforeMount: function () {
    let that = this;
    let appHeight = $(window).height();
    let autoheight = appHeight - 288 + "px";
    that.maxHeight = autoheight;
  },
  methods: {
    outPut: function () {
      //导出
      /* generate workbook object from table */
      var wb = XLSX.utils.table_to_book(
        document.querySelector("#outtableFirst")
      );
      /* get binary string as output */
      var wbout = XLSX.write(wb, {
        bookType: "xlsx",
        bookSST: true,
        type: "array",
        width: "300",
      });
      try {
        FileSaver.saveAs(
          new Blob([wbout], { type: "application/octet-stream" }),
          "数据采集.xlsx"
        );
      } catch (e) {
        if (typeof console !== "undefined") console.log(e, wbout);
      }
      return wbout;
    },
    async GetCommunityDistrict() {
      //获取社区行政区
      let that = this;
      await that
        .service({
          url: "/Dic/GetCommunityDistrict",
          method: "get",
          params: {},
        })
        .then((response) => {
          that.optionDiq = response.dtData;
        })
        .catch((data) => {});
    },
    changeCops: function (val) {
      //多选框
      this.FormAnli.Companions = val.join(",");
    },
    changeFollowUpDate: function (row, val) {
      this.setList(row);
    },
    changeDis(val) {
      this.CtyIds = "";
      this.searchData.communityId = "";
      this.optionsData = [];
      if (val) {
        this.getComselectList();
      }
    },
    // 获取社区列表
    async getComselectList() {
      let that = this;
      await that
        .service({
          url: "dic/GetCommunity",
          method: "get",
          params: {
            cName: "",
            cGroup: "",
            districtNo: that.searchData.districtNo || "",
            pageCount: 0,
            pageSize: 100,
          },
        })
        .then((resp) => {
          if (that.searchData.districtNo && that.searchData.districtNo != "") {
            that.optionsData = resp.dtData;
          } else {
            that.optionsData = [];
          }
        })
        .catch((data) => {});
    },
    Commutysp(val) {
      this.CtyIds = val.CName;
      val.SYS_ID !== undefined
        ? (this.searchData.communityId = val.SYS_ID)
        : (this.searchData.communityId = "");
    },
    formXQ6: function (val) {
      //自信程度监听
      if (parseInt(val) <= 3) {
        this.$alert(
          "请询问研究对象是否完善行动计划，以制定研究对象更容易完成和实现的行动计划。",
          "提醒",
          {
            confirmButtonText: "知道了",
          }
        );
      }
    },
    changeFollowUpDateOne: function (row, val) {
      let that = this;
      if (row.AppointState == 0) {
        this.$confirm("是否将预约状态改为已确认 , 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            row.AppointState = "1";
            that.setList(row);
          })
          .catch(() => {
            that.setList(row);
          });
      } else {
        that.setList(row);
      }
    },
    JumpUserinfo: function (row) {
      let that = this;
      that.$router.push({
        path: "/participant/editor",
        query: {
          id: row.ResearchObjectId,
          mobile: row.Mobile,
          researchNo: row.ResearchNo,
        },
      });
    },
    UserStateFilter(row, column, cellValue, index) {
      switch (cellValue) {
        case "1":
          return "活跃";
          break;
        case "2":
          return "不活跃";
          break;
        case "3":
          return "不活跃";
          break;
        case "4":
          return "不活跃";
          break;
        case "5":
          return "不活跃";
          break;
      }
    },
    handleSizeChange(val) {
      //条数改变
      this.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      //页数改变
      this.pageId = val;
      this.getList();
    },
    handleSizeChangeQ(val) {
      //条数改变
      this.pageSizeQ = val;
      this.getListQ();
    },
    handleCurrentChangeQ(val) {
      //页数改变
      this.pageIdQ = val;
      this.getListQ();
    },
    setList: function (row) {
      //修改
      let that = this;
      that
        .service({
          url: "/ResearchObject/SaveDataCollection",
          method: "post",
          data: {
            ...row,
          },
        })
        .then((response) => {
          that.$message({
            message: "修改成功",
            type: "success",
          });
          that.getList();
        })
        .catch((data) => {
          that.getList();
        });
    },
    getList() {
      //获取一级信息列表
      let that = this;
      that.loading = true;
      that
        .service({
          url: "/ResearchObject/GetDataCollection",
          method: "get",
          params: {
            pageCount: that.pageId - 1,
            pageSize: that.pageSize,
            ...that.searchData,
            startDate: that.timeDate ? that.timeDate[0] : "",
            endDate: that.timeDate ? that.timeDate[1] : "",
          },
        })
        .then((response) => {
          console.log(response);
          that.tableData = response.dtData;
          that.total = parseInt(response.dtData[0].TotalCount);
          that.loading = false;
        })
        .catch((data) => {
          that.loading = false;
        });
    },
    checkList: function () {
      this.pageId = 1;
      this.pageSize = 10;
      this.total = null;
      this.getList();
      let storageObj = this.searchData;
      this.searchData.comName = this.CtyIds;
      localStorage.setItem("dataColleManage", JSON.stringify(storageObj));
    },
    GetNurse: function () {
      let that = this;
      that
        .service({
          url: "/Sys/GetNurse",
          method: "get",
          params: {
            roleGroup: "10",
          },
        })
        .then((response) => {
          let options = response.dtData;
          console.log(response);
          for (let i of options) {
            //处理姓名账号不一致，Nan
            i.Name = i.Name || "";
            let username = i.Surname + i.Name;
            username == "undefined"
              ? (username = i.UserCode)
              : (username = username);
            i.icons = username;
          }
          that.optionsNurse = options;
        })
        .catch((data) => {});
    },
    changeNurse: function (row, val) {
      let that = this;
      this.$confirm("更换访谈人员后，请重新填写访谈时间, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          that.optionsNurse.forEach(function (item) {
            //绑定ID
            if (item.NurseName == val) {
              row.NurseId = item.NurseId;
            }
          });
          row.AppointTime = "";
          this.setList(row);
        })
        .catch(() => {
          that.$message({
            message: "已取消",
            type: "info",
          });
          that.getList();
        });
    },
  },
};
function addZero(s) {
  return s < 10 ? "0" + s : s;
}
function dateForm(data) {
  return (
    new Date(data).getFullYear() +
    "-" +
    addZero(new Date(data).getMonth() + 1) +
    "-" +
    addZero(new Date(data).getDate())
  );
}
</script>
<style scoped lang="scss">
.formX {
  .top {
    text-align: center;
  }
  ul {
    li {
      margin: 20px;
      h3 {
        color: #606266;
        font-weight: normal;
      }
      h5 {
        font-weight: normal;
        margin: 5px 0;
      }
      p {
        color: #999999;
        margin-bottom: 10px;
        margin: 10px 0px;
      }
    }
  }
}
.click_line {
  cursor: pointer;
  color: #409eff;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.4s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
.formPlebek {
  color: #0066ff;
}
.pagination-fixed {
  position: static;
}
.excelHidden {
  display: none !important;
}
</style>
